<!DOCTYPE html>
<html>

<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>一个多用户博客后台</title>
  <meta name="keywords" content="">
  <meta name="description" content="">
  <link rel="shortcut icon" href="favicon.ico">
  <link href="../public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
  <link href="../public/css/font-awesome.css?v=4.4.0" rel="stylesheet">
  <link href="../public/css/plugins/iCheck/custom.css" rel="stylesheet">
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.13.1/bootstrap-table.min.css">
  <link href="../public/css/animate.css" rel="stylesheet">
  <link href="../public/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
  <div class="wrapper wrapper-content">
    <div class="row">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5>用户管理</h5>
          <div class="ibox-tools">
            <a class="collapse-link">
              <i class="fa fa-chevron-up"></i>
            </a>


          </div>
        </div>
        <div class="ibox-content">

          <div class="example-wrap">
            <div class="example">
              <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                <a class="btn btn-primary" href="#" onclick="modelShow()">新增分类</a>
                <a class="btn btn-primary" onclick="modelShow1()">修改分类</a>
                <a class="btn btn-primary" href="/admin/deleteCategory{{curentcate.cateid}}">删除分类</a>
              </div>
              <table id="cateArt" data-height="550" data-mobile-responsive="true">
                <thead>
                  <tr>
                    <th data-field="xuhao" data-formatter="xuhao">序号</th>
                    <th data-field="_id">ID</th>
                    <th data-field="categoryId.name">分类</th>
                    <th data-field="authorId.name">作者</th>
                    <th data-field="title">标题</th>
                    <th data-field="createAt">日期</th>
                    <th data-field="countInfo.commentCount">评论</th>
                    <th data-field="top" data-formatter="zhiding">置顶</th>
                    <th data-field="good" data-formatter="jinghua">精华</th>
                    <th data-field="state" data-formatter="zhuantai">状态</th>
                    <th data-formatter="actionFormatter" data-align="center">操作</th>
                  </tr>
                </thead>
              </table>
            </div>
          </div>


        </div>
      </div>
    </div>
  </div>


  <!--弹窗-->
  <div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content animated bounceInRight">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
              class="sr-only">关闭</span> </button>
          <h4 class="modal-title">添加分类</h4>
          <small class="font-bold">添加分类</small>
        </div>
        <form id="edit-form" class="form-horizontal" method="POST" action="/admin/addCategory/">
          <div class="modal-body">
            <div class="form-group">
              <label class="col-sm-2 control-label">分类父级:</label>
              <div class="col-sm-10">
                <select class="form-control" name="fatherId" id="fatherId">
                  <option value="0">主分类</option>
                  {{each allcate}}
                  <option value="{{$value.cateid}}">{{$value.name}}</option>
                  {{/each}}
                </select>
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">分类名称:</label>
              <div class="col-sm-10">
                <input type="text" class="form-control" name="name" value="">
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
              <label class="col-sm-2 control-label">分类描述</label>
              <div class="col-sm-10">
                <textarea class="form-control" name="info"></textarea>
              </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div>
              <input type="checkbox" class="i-checks" name="isNav" value="true"> 加入导航
            </div>
          </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" onClick="sub()">保存</button>
      </div>
      </form>
    </div>
  </div>
  </div>

  <!-- 修改 -->
  <div class="modal inmodal" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content animated bounceInRight">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
              class="sr-only">关闭</span> </button>
          <h4 class="modal-title">修改分类</h4>
          <small class="font-bold">修改分类信息</small>
        </div>
        <form id="edit-form1" class="form-horizontal" method="POST" action="/admin/editCategory{{curentcate.cateid}}">
        <div class="modal-body">
          <div class="form-group">
            <label class="col-sm-2 control-label">分类父级:</label>
            <div class="col-sm-10">
              <select class="form-control" name="fatherId" id="fatherId">
                <option value="0">主分类</option>
                {{each allcate}}
                <option value="{{$value.cateid}}">{{$value.name}}</option>
                {{/each}}
              </select>
            </div>
          </div>
          <div class="hr-line-dashed"></div>
          <div class="form-group">
            <label class="col-sm-2 control-label">分类名称:</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" name="name" value=" {{curentcate.name}} ">
            </div>
          </div>
          <div class="hr-line-dashed"></div>
          <div class="form-group">
            <label class="col-sm-2 control-label">分类描述</label>
            <div class="col-sm-10">
              <textarea class="form-control" name="info"> {{curentcate.info}} </textarea>
            </div>
          </div>
          <div class="hr-line-dashed"></div>
          <div>
            {{if (curentcate.isNav==false)}}
                <input type="checkbox" class="i-checks" name="isNav" value="true"> 加入导航
             {{else}}
              <input type="checkbox" class="i-checks" name="isNav" value="false"> 取消导航
            {{/if}}
          </div>
        </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" onClick="sub1()">保存</button>
      </div>
      </form>
    </div>
  </div>
  </div>






  <!-- 全局js -->
  <script src="../public/js/jquery.min.js?v=2.1.4"></script>
  <script src="../public/js/bootstrap.min.js?v=3.3.6"></script>
  <script src="../public/js/plugins/layer/layer.min.js"></script>

  <!-- 自定义js -->
  <script src="../public/js/content.js"></script>
  <!-- iCheck -->
  <script src="../public/js/plugins/iCheck/icheck.min.js"></script>

  <!-- Bootstrap table -->
  <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.13.1/bootstrap-table.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.13.1/locale/bootstrap-table-zh-CN.min.js"></script>

  <script>
    $(document).ready(function () {
      $('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
      });
    });
  </script>


  <script>
    function modelShow() {
      $('#myModal').modal('show')
    }
    function modelShow1(id) {
      $('#myModal1').modal('show')
    }
    var parent = window.parent;
    function sub() {
      $('#edit-form').submit()
    }
    function sub1() {
      $('#edit-form1').submit()
    }

    function EditViewById(id, tit) {
      var url = '/admin/edit-acticle' + id
      var num = parseInt(Math.random() * 100)
      var index = 100 + num
      console.log(tit)
      var name = tit.substring(0, 8) + '...'
      window.parent.openNew(url, index, name)
    }

    function getSelectRow() {
      console.log($("#exampleTableEvents").bootstrapTable('getSelections'))
    }
    //操作栏的格式化
    function actionFormatter(value, row, index) {
      var result = "";
      result += "<a href='javascript:;' class='btn btn-xs blue' onclick=\"EditViewById('" + row._id + "','" + row.title + "')\" title='编辑'><span class='glyphicon glyphicon-pencil'></span></a>";
      result += "<a href='/admin/deletearc" + row._id + "' class='btn btn-xs red'  title='删除' target='_self'><span class='glyphicon glyphicon-remove'></span></a>";
      return result;
    }

    function jinghua(str){
      if(str){
        return 'GOOD'
      }else{
        return ''
      }
    }
    function zhiding(str){
      if(str){
        return 'TOP'
      }else{
        return ''
      }
    }
    function zhuantai(str){
      if(str){
        return '公开'
      }else{
        return '不公开'
      }
    }

    $('#cateArt').bootstrapTable({
      url: "/admin/getCategoryArt" + {{curentcate.cateid}},
      method: 'get',
      search: true,
      cache: false,
      contentType: "application/x-www-form-urlencoded; charset=UTF-8",
      pagination: true,
      showRefresh: true,
      showColumns: true,
      iconSize: 'outline',
      toolbar: '#exampleTableEventsToolbar',
      icons: {
        refresh: 'glyphicon-repeat',
        columns: 'glyphicon-list'
      }
    });
    $('#cateArt').bootstrapTable('hideColumn', '_id'); //隐藏_id
    function xuhao(value, row, index) {
      var pageNumber = $('#cateArt').bootstrapTable('getOptions').pageNumber;
      var pageSize = $('#cateArt').bootstrapTable('getOptions').pageSize;
      return (pageNumber - 1) * pageSize + index + 1;
    }

  </script>





</body>

</html>